home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Tool Chest / Text / WASTE / WASTE 1.1.2 Distribution / Pseudo-UPI for THINK Pascal / Drag.p < prev    next >
Encoding:
Text File  |  1995-10-12  |  12.9 KB  |  414 lines  |  [TEXT/PJMM]

  1. unit Drag;
  2.  
  3. { Pascal Interface to the Macintosh Libraries }
  4.  
  5. { Copyright © Apple Computer Inc. }
  6. { All Rights Reserved }
  7.  
  8. { Adapted for use with THINK Pascal 4.0.x by Marco Piovanelli }
  9.  
  10. interface
  11.     uses
  12.         Types, AppleEvents;
  13.  
  14.     const
  15.  
  16. { gestalt constants (!!! transplanted from GestaltEqu.p !!!) }
  17.         gestaltDragMgrAttr = 'drag';                        { Drag Manager attributes }
  18.         gestaltDragMgrPresent = 0;                            { Drag Manager is present }
  19.         gestaltDragMgrFloatingWind = 1;                            { Drag Manager supports floating windows }
  20.         gestaltPPCDragLibPresent = 2;                            { Drag Manager PPC DragLib is present }
  21.  
  22. { Drag Manager error codes (!!! transplanted from Errors.p !!!) }
  23.         badDragRefErr = -1850;                        { unknown drag reference }
  24.         badDragItemErr = -1851;                        { unknown drag item reference }
  25.         badDragFlavorErr = -1852;                        { unknown flavor type }
  26.         duplicateFlavorErr = -1853;                        { flavor type already exists }
  27.         cantGetFlavorErr = -1854;                        { error while trying to get flavor data }
  28.         duplicateHandlerErr = -1855;                        { handler already exists }
  29.         handlerNotFoundErr = -1856;                        { handler not found }
  30.         dragNotAcceptedErr = -1857;                        { drag was not accepted by receiver }
  31.  
  32. { Flavor Flags }
  33.         flavorSenderOnly = $00000001;                    { flavor is available to sender only }
  34.         flavorSenderTranslated = $00000002;                    { flavor is translated by sender }
  35.         flavorNotSaved = $00000004;                    { flavor should not be saved }
  36.         flavorSystemTranslated = $00000100;                    { flavor is translated by system }
  37.  
  38.  
  39.     type
  40.         FlavorFlags = LONGINT;
  41.  
  42.  
  43.     const
  44. { Drag Attributes }
  45.         dragHasLeftSenderWindow = $00000001;                    { drag has left the source window since TrackDrag }
  46.         dragInsideSenderApplication = $00000002;                    { drag is occurring within the sender application }
  47.         dragInsideSenderWindow = $00000004;                    { drag is occurring within the sender window }
  48.  
  49.  
  50.     type
  51.         DragAttributes = LONGINT;
  52.  
  53.  
  54.     const
  55. { Special Flavor Types }
  56.         flavorTypeHFS = 'hfs ';                        { flavor type for HFS data }
  57.         flavorTypePromiseHFS = 'phfs';                        { flavor type for promised HFS data }
  58.         flavorTypeDirectory = 'diry';
  59.  
  60. { Drag Tracking Handler Messages }
  61.         dragTrackingEnterHandler = 1;                            { drag has entered handler }
  62.         dragTrackingEnterWindow = 2;                            { drag has entered window }
  63.         dragTrackingInWindow = 3;                            { drag is moving within window }
  64.         dragTrackingLeaveWindow = 4;                            { drag has exited window }
  65.         dragTrackingLeaveHandler = 5;                            { drag has exited handler }
  66.  
  67.  
  68.     type
  69.         DragTrackingMessage = INTEGER;
  70.  
  71.  
  72.     const
  73. { Drag Drawing Procedure Messages }
  74.         dragRegionBegin = 1;                            { initialize drawing }
  75.         dragRegionDraw = 2;                            { draw drag feedback }
  76.         dragRegionHide = 3;                            { hide drag feedback }
  77.         dragRegionIdle = 4;                            { drag feedback idle time }
  78.         dragRegionEnd = 5;                            { end of drawing }
  79.  
  80.  
  81.     type
  82.         DragRegionMessage = INTEGER;
  83.  
  84.  
  85.     const
  86. { Zoom Acceleration }
  87.         zoomNoAcceleration = 0;                            { use linear interpolation }
  88.         zoomAccelerate = 1;                            { ramp up step size }
  89.         zoomDecelerate = 2;                            { ramp down step size }
  90.  
  91.  
  92.     type
  93.         ZoomAcceleration = INTEGER;
  94.  
  95. { Drag Manager Data Types }
  96.         DragReference = LONGINT;
  97.  
  98.         ItemReference = LONGINT;
  99.  
  100.         FlavorType = ResType;
  101.  
  102. { HFS Flavors }
  103.         HFSFlavor = record
  104.                 fileType: OSType;                                    { file type }
  105.                 fileCreator: OSType;                                    { file creator }
  106.                 fdFlags: INTEGER;                                { Finder flags }
  107.                 fileSpec: FSSpec;                                    { file system specification }
  108.             end;
  109.         PromiseHFSFlavor = record
  110.                 fileType: OSType;                                    { file type }
  111.                 fileCreator: OSType;                                    { file creator }
  112.                 fdFlags: INTEGER;                                { Finder flags }
  113.                 promisedFlavor: FlavorType;                                { promised flavor containing an FSSpec }
  114.             end;
  115. { Application-Defined Drag Handler Routines }
  116.         DragTrackingHandlerProcPtr = ProcPtr;  { FUNCTION DragTrackingHandler(message: DragTrackingMessage; theWindow: WindowPtr; handlerRefCon: UNIV Ptr; theDragRef: DragReference): OSErr; }
  117.         DragTrackingHandlerUPP = UniversalProcPtr;
  118.  
  119.     const
  120.         uppDragTrackingHandlerProcInfo = $00003FA0; { FUNCTION (2 byte param, 4 byte param, 4 byte param, 4 byte param): 2 byte result; }
  121.  
  122.     function NewDragTrackingHandlerProc (userRoutine: DragTrackingHandlerProcPtr): DragTrackingHandlerUPP;
  123.     inline
  124.         $2E9F;
  125.  
  126.     function CallDragTrackingHandlerProc (message: DragTrackingMessage;
  127.                                     theWindow: WindowPtr;
  128.                                     handlerRefCon: univ Ptr;
  129.                                     theDragRef: DragReference;
  130.                                     userRoutine: DragTrackingHandlerUPP): OSErr;
  131.     inline
  132.         $205F, $4E90;
  133.  
  134.     type
  135.         DragTrackingHandler = DragTrackingHandlerUPP;
  136.  
  137.         DragReceiveHandlerProcPtr = ProcPtr;  { FUNCTION DragReceiveHandler(theWindow: WindowPtr; handlerRefCon: UNIV Ptr; theDragRef: DragReference): OSErr; }
  138.         DragReceiveHandlerUPP = UniversalProcPtr;
  139.  
  140.     const
  141.         uppDragReceiveHandlerProcInfo = $00000FE0; { FUNCTION (4 byte param, 4 byte param, 4 byte param): 2 byte result; }
  142.  
  143.     function NewDragReceiveHandlerProc (userRoutine: DragReceiveHandlerProcPtr): DragReceiveHandlerUPP;
  144.     inline
  145.         $2E9F;
  146.  
  147.     function CallDragReceiveHandlerProc (theWindow: WindowPtr;
  148.                                     handlerRefCon: univ Ptr;
  149.                                     theDragRef: DragReference;
  150.                                     userRoutine: DragReceiveHandlerUPP): OSErr;
  151.     inline
  152.         $205F, $4E90;
  153.  
  154.     type
  155.         DragReceiveHandler = DragReceiveHandlerUPP;
  156.  
  157. { Application-Defined Routines }
  158.         DragSendDataProcPtr = ProcPtr;  { FUNCTION DragSendData(theType: FlavorType; dragSendRefCon: UNIV Ptr; theItemRef: ItemReference; theDragRef: DragReference): OSErr; }
  159.         DragSendDataUPP = UniversalProcPtr;
  160.  
  161.     const
  162.         uppDragSendDataProcInfo = $00003FE0; { FUNCTION (4 byte param, 4 byte param, 4 byte param, 4 byte param): 2 byte result; }
  163.  
  164.     function NewDragSendDataProc (userRoutine: DragSendDataProcPtr): DragSendDataUPP;
  165.     inline
  166.         $2E9F;
  167.  
  168.     function CallDragSendDataProc (theType: FlavorType;
  169.                                     dragSendRefCon: univ Ptr;
  170.                                     theItemRef: ItemReference;
  171.                                     theDragRef: DragReference;
  172.                                     userRoutine: DragSendDataUPP): OSErr;
  173.     inline
  174.         $205F, $4E90;
  175.  
  176.     type
  177.         DragSendDataProc = DragSendDataUPP;
  178.  
  179.         DragInputProcPtr = ProcPtr;  { FUNCTION DragInput(VAR mouse: Point; VAR modifiers: INTEGER; dragInputRefCon: UNIV Ptr; theDragRef: DragReference): OSErr; }
  180.         DragInputUPP = UniversalProcPtr;
  181.  
  182.     const
  183.         uppDragInputProcInfo = $00003FE0; { FUNCTION (4 byte param, 4 byte param, 4 byte param, 4 byte param): 2 byte result; }
  184.  
  185.     function NewDragInputProc (userRoutine: DragInputProcPtr): DragInputUPP;
  186.     inline
  187.         $2E9F;
  188.  
  189.     function CallDragInputProc (var mouse: Point;
  190.                                     var modifiers: INTEGER;
  191.                                     dragInputRefCon: univ Ptr;
  192.                                     theDragRef: DragReference;
  193.                                     userRoutine: DragInputUPP): OSErr;
  194.     inline
  195.         $205F, $4E90;
  196.  
  197.     type
  198.         DragInputProc = DragInputUPP;
  199.  
  200.         DragDrawingProcPtr = ProcPtr;  { FUNCTION DragDrawing(message: DragRegionMessage; showRegion: RgnHandle; showOrigin: Point; hideRegion: RgnHandle; hideOrigin: Point; dragDrawingRefCon: UNIV Ptr; theDragRef: DragReference): OSErr; }
  201.         DragDrawingUPP = UniversalProcPtr;
  202.  
  203.     const
  204.         uppDragDrawingProcInfo = $000FFFA0; { FUNCTION (2 byte param, 4 byte param, 4 byte param, 4 byte param, 4 byte param, 4 byte param, 4 byte param): 2 byte result; }
  205.  
  206.     function NewDragDrawingProc (userRoutine: DragDrawingProcPtr): DragDrawingUPP;
  207.     inline
  208.         $2E9F;
  209.  
  210.     function CallDragDrawingProc (message: DragRegionMessage;
  211.                                     showRegion: RgnHandle;
  212.                                     showOrigin: Point;
  213.                                     hideRegion: RgnHandle;
  214.                                     hideOrigin: Point;
  215.                                     dragDrawingRefCon: univ Ptr;
  216.                                     theDragRef: DragReference;
  217.                                     userRoutine: DragDrawingUPP): OSErr;
  218.     inline
  219.         $205F, $4E90;
  220.  
  221.     type
  222.         DragDrawingProc = DragDrawingUPP;
  223.  
  224. { Drag Manager Routines }
  225. { Installing and Removing Drag Handlers }
  226.  
  227.     function InstallTrackingHandler (trackingHandler: DragTrackingHandler;
  228.                                     theWindow: WindowPtr;
  229.                                     handlerRefCon: univ Ptr): OSErr;
  230.     inline
  231.         $7001, $ABED;
  232.     function InstallReceiveHandler (receiveHandler: DragReceiveHandler;
  233.                                     theWindow: WindowPtr;
  234.                                     handlerRefCon: univ Ptr): OSErr;
  235.     inline
  236.         $7002, $ABED;
  237.     function RemoveTrackingHandler (trackingHandler: DragTrackingHandler;
  238.                                     theWindow: WindowPtr): OSErr;
  239.     inline
  240.         $7003, $ABED;
  241.     function RemoveReceiveHandler (receiveHandler: DragReceiveHandler;
  242.                                     theWindow: WindowPtr): OSErr;
  243.     inline
  244.         $7004, $ABED;
  245. { Creating and Disposing Drag References }
  246.     function NewDrag (var theDragRef: DragReference): OSErr;
  247.     inline
  248.         $7005, $ABED;
  249.     function DisposeDrag (theDragRef: DragReference): OSErr;
  250.     inline
  251.         $7006, $ABED;
  252. { Adding Drag Item Flavors }
  253.     function AddDragItemFlavor (theDragRef: DragReference;
  254.                                     theItemRef: ItemReference;
  255.                                     theType: FlavorType;
  256.                                     dataPtr: univ Ptr;
  257.                                     dataSize: Size;
  258.                                     theFlags: FlavorFlags): OSErr;
  259.     inline
  260.         $7007, $ABED;
  261.     function SetDragItemFlavorData (theDragRef: DragReference;
  262.                                     theItemRef: ItemReference;
  263.                                     theType: FlavorType;
  264.                                     dataPtr: univ Ptr;
  265.                                     dataSize: Size;
  266.                                     dataOffset: LONGINT): OSErr;
  267.     inline
  268.         $7009, $ABED;
  269. { Providing Drag Callback Procedures }
  270.     function SetDragSendProc (theDragRef: DragReference;
  271.                                     sendProc: DragSendDataProc;
  272.                                     dragSendRefCon: univ Ptr): OSErr;
  273.     inline
  274.         $700A, $ABED;
  275.     function SetDragInputProc (theDragRef: DragReference;
  276.                                     inputProc: DragInputProc;
  277.                                     dragInputRefCon: univ Ptr): OSErr;
  278.     inline
  279.         $700B, $ABED;
  280.     function SetDragDrawingProc (theDragRef: DragReference;
  281.                                     drawingProc: DragDrawingProc;
  282.                                     dragDrawingRefCon: univ Ptr): OSErr;
  283.     inline
  284.         $700C, $ABED;
  285. { Performing a Drag }
  286.     function TrackDrag (theDragRef: DragReference; {CONST}
  287.                                     var theEvent: EventRecord;
  288.                                     theRegion: RgnHandle): OSErr;
  289.     inline
  290.         $700D, $ABED;
  291. { Getting Drag Item Information }
  292.     function CountDragItems (theDragRef: DragReference;
  293.                                     var numItems: INTEGER): OSErr;
  294.     inline
  295.         $700E, $ABED;
  296.     function GetDragItemReferenceNumber (theDragRef: DragReference;
  297.                                     index: INTEGER;
  298.                                     var theItemRef: ItemReference): OSErr;
  299.     inline
  300.         $700F, $ABED;
  301.     function CountDragItemFlavors (theDragRef: DragReference;
  302.                                     theItemRef: ItemReference;
  303.                                     var numFlavors: INTEGER): OSErr;
  304.     inline
  305.         $7010, $ABED;
  306.     function GetFlavorType (theDragRef: DragReference;
  307.                                     theItemRef: ItemReference;
  308.                                     index: INTEGER;
  309.                                     var theType: FlavorType): OSErr;
  310.     inline
  311.         $7011, $ABED;
  312.     function GetFlavorFlags (theDragRef: DragReference;
  313.                                     theItemRef: ItemReference;
  314.                                     theType: FlavorType;
  315.                                     var theFlags: FlavorFlags): OSErr;
  316.     inline
  317.         $7012, $ABED;
  318.     function GetFlavorDataSize (theDragRef: DragReference;
  319.                                     theItemRef: ItemReference;
  320.                                     theType: FlavorType;
  321.                                     var dataSize: Size): OSErr;
  322.     inline
  323.         $7013, $ABED;
  324.     function GetFlavorData (theDragRef: DragReference;
  325.                                     theItemRef: ItemReference;
  326.                                     theType: FlavorType;
  327.                                     dataPtr: univ Ptr;
  328.                                     var dataSize: Size;
  329.                                     dataOffset: LONGINT): OSErr;
  330.     inline
  331.         $7014, $ABED;
  332.     function GetDragItemBounds (theDragRef: DragReference;
  333.                                     theItemRef: ItemReference;
  334.                                     var itemBounds: Rect): OSErr;
  335.     inline
  336.         $7015, $ABED;
  337.     function SetDragItemBounds (theDragRef: DragReference;
  338.                                     theItemRef: ItemReference; {CONST}
  339.                                     var itemBounds: Rect): OSErr;
  340.     inline
  341.         $7016, $ABED;
  342.     function GetDropLocation (theDragRef: DragReference;
  343.                                     var dropLocation: AEDesc): OSErr;
  344.     inline
  345.         $7017, $ABED;
  346.     function SetDropLocation (theDragRef: DragReference; {CONST}
  347.                                     var dropLocation: AEDesc): OSErr;
  348.     inline
  349.         $7018, $ABED;
  350. { Getting Information About a Drag }
  351.     function GetDragAttributes (theDragRef: DragReference;
  352.                                     var flags: DragAttributes): OSErr;
  353.     inline
  354.         $7019, $ABED;
  355.     function GetDragMouse (theDragRef: DragReference;
  356.                                     var mouse: Point;
  357.                                     var pinnedMouse: Point): OSErr;
  358.     inline
  359.         $701A, $ABED;
  360.     function SetDragMouse (theDragRef: DragReference;
  361.                                     pinnedMouse: Point): OSErr;
  362.     inline
  363.         $701B, $ABED;
  364.     function GetDragOrigin (theDragRef: DragReference;
  365.                                     var initialMouse: Point): OSErr;
  366.     inline
  367.         $701C, $ABED;
  368.     function GetDragModifiers (theDragRef: DragReference;
  369.                                     var modifiers: INTEGER;
  370.                                     var mouseDownModifiers: INTEGER;
  371.                                     var mouseUpModifiers: INTEGER): OSErr;
  372.     inline
  373.         $701D, $ABED;
  374. { Drag Highlighting }
  375.     function ShowDragHilite (theDragRef: DragReference;
  376.                                     hiliteFrame: RgnHandle;
  377.                                     inside: BOOLEAN): OSErr;
  378.     inline
  379.         $701E, $ABED;
  380.     function HideDragHilite (theDragRef: DragReference): OSErr;
  381.     inline
  382.         $701F, $ABED;
  383.     function DragPreScroll (theDragRef: DragReference;
  384.                                     dH: INTEGER;
  385.                                     dV: INTEGER): OSErr;
  386.     inline
  387.         $7020, $ABED;
  388.     function DragPostScroll (theDragRef: DragReference): OSErr;
  389.     inline
  390.         $7021, $ABED;
  391.     function UpdateDragHilite (theDragRef: DragReference;
  392.                                     updateRgn: RgnHandle): OSErr;
  393.     inline
  394.         $7022, $ABED;
  395. { Drag Manager Utilities }
  396.     function WaitMouseMoved (initialMouse: Point): BOOLEAN;
  397.     inline
  398.         $7023, $ABED;
  399.     function ZoomRects ({CONST}
  400.                                     var fromRect: Rect; {CONST}
  401.                                     var toRect: Rect;
  402.                                     zoomSteps: INTEGER;
  403.                                     acceleration: ZoomAcceleration): OSErr;
  404.     inline
  405.         $7024, $ABED;
  406.     function ZoomRegion (region: RgnHandle;
  407.                                     zoomDistance: Point;
  408.                                     zoomSteps: INTEGER;
  409.                                     acceleration: ZoomAcceleration): OSErr;
  410.     inline
  411.         $7025, $ABED;
  412.  
  413. implementation
  414. end.